import Link from './link/index';
import Interface from './interface/index';
import WidgetMethod from './widgetMethod/index';
import Vue from 'vue';

Vue.component(Link.name, Link);
Vue.component(Interface.name, Interface);
Vue.component(WidgetMethod.name, WidgetMethod);

const list = [Link, Interface, WidgetMethod];
const map = list.reduce((prev, current) => {
  prev[current.name] = current;
  return prev;
}, {});

export default {
  list: list,
  map: map,
  doAction(vue, action, params) {
    // console.log('doAction', vue, action, params);
    if (!map[action.actionType]) {
      return;
    }
    // 获取到此类action的处理者，进行处理
    const handler = map[action.actionType].handler;
    handler.process(vue, action, params);

  }
}
